package org.webflux.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.webflux.consumer.pojo.User;
import org.webflux.consumer.service.UserFeignWebFlux;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@RestController
@RequestMapping("t")
@SuppressWarnings("ALL")
public class UserConsumer {

    @Autowired
    private UserFeignWebFlux userFeignWebFlux;

    @GetMapping("info")
    public Mono<User> getUserInfo(String id){
      return userFeignWebFlux.findById(id);
    }

    @GetMapping("all")
    public Flux<User> getUserInfo(){
      return userFeignWebFlux.findAll();
    }

    @PostMapping("add")
    public Mono<String> addUser(@RequestBody User user){
        return userFeignWebFlux.createUser(user);
    }

}
